<?php


namespace RedMVC\Form\Element;
use RedMVC;

/**
 * File class
 *
 * @category    RedMVC
 * @package     Form
 * @subpackage  Element
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class File extends AElement{

    protected $_file;

    public function setFile(RedMVC\Form\File $file){
        $this->_file = $file;
    }

    public function getFile(){
        return $this->_file;
    }

    public function setForm(RedMVC\Form $form){
        $this->form = $form;
        $form->setMethod(RedMVC\Form::FORM_METHOD_POST);
        $form->addAttribute('enctype', 'multipart/form-data');        
    }

    public function getValidators(){
        return $this->validators;
    }

    public function render(){
        return '<input type="file" name="'.$this->varname.'"'.$this->form->buildAttributes($this->attributes).' />';
    }
}